package com.hongkzh.www.look.enterprise.userinfo.presenter;


import android.util.Log;

import com.hongkzh.www.look.enterprise.userinfo.model.bean.MediaVideoBean;
import com.hongkzh.www.other.okhttp.CallBackUtil;
import com.hongkzh.www.other.okhttp.OkhttpUtil;
import com.hongkzh.www.look.enterprise.userinfo.view.iview.MediaVideoIView;
import com.hongkzh.www.presenter.BasePresenter;

import okhttp3.Call;

import static com.hongkzh.www.other.api.Api.GETUSERADVLIST;


/**
 * Created by as on 2018/3/31.
 * 自媒体视频模块
 */

public class MediaVideoPresenter extends BasePresenter<MediaVideoIView> {

    private boolean lastPage=false;


    @Override
    public void attachView(MediaVideoIView iView) {
        super.attachView(iView);
    }


    public void getMediaVideo(String uid,String pageNumber,String sortId,String sortValue){
        String url= GETUSERADVLIST(uid,pageNumber,sortId,sortValue);
        Log.i("gaoshan","请求的多媒体视频列表的url============="+url);
        OkhttpUtil.okHttpPost(url, new CallBackUtil<MediaVideoBean>() {
            @Override
            public void onFailure(Call call, Exception e) {

            }

            @Override
            public void onResponse(MediaVideoBean response) {
                lastPage=response.getData().isLastPage();
                if (lastPage) getIView().onLastPage(lastPage);
                getIView().onShowMediaVideoList(response);
            }
        });
    }


    @Override
    public MediaVideoIView getIView() {
        return super.getIView();
    }

    @Override
    public void detachView() {
        super.detachView();
    }
}